<extend name="Layout/ins_page" />
<block name="content">
	<form method="post" name="form_adv_search" id="form_adv_search">
		<div class="adv_search panel panel-default"  id="adv_search">
			<div class="panel-heading">
				<div class="row">
					<h4 class="col-xs-6">应收/付款</h4>
					<div class="col-xs-6 text-right">
						<a  class="btn btn-sm btn-info" onclick="submit_adv_search();">搜索</a>
						<a  class="btn btn-sm btn-info" href="{:U('sured')}">重置</a>
					</div>
				</div>
			</div>
			<div class="panel-body">
				<div class="form-group col-sm-6">
					<label class="col-sm-4 control-label" for="li_name">公司名称：</label>
					<div class="col-sm-8">
						<input  class="form-control" type="text" id="li_name" name="li_name" value="{$li_name}" />
					</div>
				</div>
				<div class="form-group col-sm-6">
					<label class="col-sm-4 control-label" for="eq_type">类别：</label>
					<div class="col-sm-8">
						<select id="type" name="eq_type" class="form-control">
							<option value="">请选择</option>
							<foreach name="type" item="vo">
								<option value="{$key}" <if condition="$key eq $eq_type">selected</if> >{$vo}</option>		
							</foreach>
						</select>
					</div>
				</div>
			</div>
		</div>
	</form>
	<div class="space-8"></div>
	<if condition="$auth['write']">
		<div class="operate panel panel-default">
			<div class="panel-body">
				<div class="pull-right">
					<a class="btn btn-sm btn-primary" onclick="add_sured()">添加</a>
				</div>
			</div>
		</div>
	</if>
	<div class="ul_table ul_table_responsive">
		<ul>
			<li class="thead">
				<span class="col-10 ">客户名称</span>
				<span class="col-10 ">类别</span>
				<span class="col-10 ">金额</span>
				<span class="col-10 ">创建时间</span>
				<span class="col-8 ">操作</span>
			</li>
			<empty name="list">
				<li class="no-data">
					没找到数据
				</li>
				<else/>
				<foreach name="list" item="vo">
					<li class="tbody data_item">
						<span class="col-10">{$vo.name}</span>
						<span class="col-10">
							<if condition="$vo[type] eq 1">应收款<else/>应付款</if>
						</span>
						<if condition="$vo[type] eq 1">
							<span class="col-10 data data_1">{$vo.money}</span>
						<else/>
							<span class="col-10 data data_2">{$vo.money}</span>
						</if>
						<span class="col-10">{$vo.create_at}</span>
						<span class="col-8"> <a href="{:U('edit_sured','id='.$vo['id'])}">编辑</a>  <a href="{:U('deletePayReceive','id='.$vo['id'])}">删除</a></span>
					</li>
				</foreach>
				<li class="tbody data_total">
					<span class="col-10 ">&nbsp;</span>
					<span class="col-10 text-center">应收款:<span class="data_1"></span></span>
					<span class="col-10 text-center">应付款:<span class="data_2"></span></span>
					<span class="col-10 text-center">合计:<span class="data_3"></span></span>
					<span class="col-8 ">&nbsp;</span>
				</li>
				<div class="pagination">{$page}</div>
			</empty>
		</ul>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		function add_sured() {
			window.open("{:U('add_sured')}", "_self");
		}
		
		$(document).ready(function() {
			set_return_url();
			total_init();
		});
		
		function total_init() {
			
			var total_1 = 0;
			var total_2 = 0;
			$('.data_item .data_1').each(function(){
				total_1 = total_1 + parseFloat($(this).text());
			})
			$('.data_item .data_2').each(function(){
				total_2 = total_2 + parseFloat($(this).text());
			})
			$('.data_total .data_1').text(total_1.toFixed(2));
			$('.data_total .data_2').text(total_2.toFixed(2));
			$('.data_total .data_3').text((total_1 - total_2).toFixed(2));
		}
		
	</script>
</block>